<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "acc_pay_address".
 *
 * @property integer $acc_pay_address_id
 * @property integer $acc_id
 * @property integer $pay_type_id
 * @property string $pay_address
 *
 * @property Account $acc
 * @property PaymentType $payType
 * @property Payment[] $payments
 */
class AccPayAddress extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'acc_pay_address';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['acc_id', 'pay_type_id', 'pay_address'], 'required'],
            [['acc_id', 'pay_type_id'], 'integer'],
            [['pay_address'], 'string', 'max' => 50]
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'acc_pay_address_id' => 'Acc Pay Address ID',
            'acc_id' => 'Acc ID',
            'pay_type_id' => 'Pay Type ID',
            'pay_address' => 'Địa chỉ thanh toán',
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getUser()
    {
        return $this->hasOne(User::className(), ['acc_id' => 'acc_id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getPayType()
    {
        return $this->hasOne(PaymentType::className(), ['type_id' => 'pay_type_id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getPayments()
    {
        return $this->hasMany(Payment::className(), ['acc_pay_add_id' => 'acc_pay_address_id']);
    }
}
